package com.restaurant.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.restaurant.domain.Menu;
import com.restaurant.domain.TempPerson;
import com.restaurant.service.MenuService;

@Component
@RequestMapping(value = "/action/service")
public class TestController {

	private final String queryLoadAllMenu = "from Menu where isdeleted = false";
	
	@Autowired
	private MenuService objMenuService;
	
//	@RequestMapping(method=RequestMethod.GET, value="/emp/{id}")//,headers="Accept=application/json"
//	public @ResponseBody Menu getMenu(@PathVariable String id) {
//		Menu e = null;
//		try {
//			e = objMenuService.loadByPrimaryKey(new Long(id));
//		} catch (Exception e1) {
//			e1.printStackTrace();
//		}
//		return e;
//	}
//		
//	@RequestMapping(method=RequestMethod.GET, value="/emps")//, headers="Accept=application/json"
//	public @ResponseBody List<Menu> getAllEmp() {
//		List<Menu> menuList = null;
//		try {
//			menuList = objMenuService.loadByHql(queryLoadAllMenu);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return menuList;
//	}
	
	@RequestMapping(value="/menus/{menuString}",method=RequestMethod.GET)//, headers="Accept=application/json")
	@ResponseBody
	public List<Menu> getAllEmpsJSON(HttpServletRequest request, @PathVariable String menuString, @RequestParam("name") String name) {
		List<Menu> menuList = null;
		try {
			menuList = objMenuService.loadByHql(queryLoadAllMenu);
		} catch (Exception e) {
			e.printStackTrace();
		}
		//response.setContentType("application/json");
		return menuList;
	}
}
